/*
 * Copyright © 2023
 * @Author: zhangxiang
 * @Date: 2023-05-15 16:19:51
 * @LastEditors: 976901273@qq.com
 * @LastEditTime: 2023-09-26 17:00:32
 * @Description: 运维分析 相关接口
 * 来源：调度平台cnap-V2.1 自智运维 告警中心
 * 前缀 /cnap/monitor
 *
 */

import request from '@/utils/request'
import request2 from '@/utils/request2'

const PREFIX = '/cnap'

/**
 * @description: 获取告警列表
 * @param {*} data
 * @return {*}
 */
export function getAlarmList(data) {
  return request({
    url: PREFIX + '/monitor/statistic/alarm/list',
    method: 'post',
    data
  })
}

/**
 * @description: 删除告警
 * @param {*} id
 * @return {*}
 */
export function deleteAlarm(id) {
  return request({
    url: PREFIX + '/monitor/statistic/alarm/delete/' + id,
    method: 'delete'
  })
}

/**
 * @description: 获取告警统计
 * @param {*} type
 * @return {*}
 */
export function getAlarmChart(type) {
  return request({
    url: PREFIX + '/monitor/statistic/alarm/chart/' + type,
    method: 'get'
  })
}

/**
 * @description: 获取告警规则列表
 * @param {*} data
 * @return {*}
 */
export function getRuleList(data) {
  return request({
    url: PREFIX + '/monitor/statistic/rule/list',
    method: 'post',
    data
  })
}

/**
 * @description: 添加智能告警规则
 * @param {*} data
 * @return {*}
 */
export function addIntelligentRule(data) {
  return request({
    url: PREFIX + '/monitor/statistic/rule/intelligent/add',
    method: 'post',
    data
  })
}

/**
 * @description: 更新智能告警规则
 * @param {*} data
 * @return {*}
 */
export function updateIntelligentRule(data) {
  return request({
    url: PREFIX + '/monitor/statistic/rule/intelligent/update',
    method: 'post',
    data
  })
}

/**
 * @description: 添加告警规则
 * @param {*} data
 * @return {*}
 */
export function addRule(data) {
  return request({
    url: PREFIX + '/monitor/statistic/rule/add',
    method: 'post',
    data
  })
}

/**
 * @description: 更新告警规则
 * @param {*} data
 * @return {*}
 */
export function updateRule(data) {
  return request({
    url: PREFIX + '/monitor/statistic/rule/update',
    method: 'post',
    data
  })
}

/**
 * @description: 删除告警规则
 * @param {*} data
 * @return {*}
 */
export function deleteRule(id) {
  return request({
    url: PREFIX + '/monitor/statistic/rule/delete/' + id,
    method: 'delete'
  })
}

/**
 * @description: 查询指定时间的k8s事件信息
 * @param {*} data
 * @return {*}
 */
export function getK8sEvent(data) {
  return request({
    url: PREFIX + '/monitor/statistic/k8s-event/chart',
    method: 'post',
    data
  })
}

/**
 * @description: 查询k8s事件详情
 * @param {*} data
 * @return {*}
 */
export function getK8sEventDetail(data) {
  return request({
    url: PREFIX + '/monitor/statistic/k8s-event/detail',
    method: 'post',
    data
  })
}

/**
 * @description: 查询操作日志
 * @param {*} data
 * @return {*}
 */
export function getLogList(data) {
  return request({
    url: PREFIX + '/monitor/statistic/log/list',
    method: 'post',
    data
  })
}

/**
 * @description: 获取告警导出数据
 * @param {*} params
 * @return {*}
 */
export function getAlarmExport(params) {
  return request2({
    url: PREFIX + '/monitor/export/type/alarm',
    method: 'get',
    headers: {
      'Content-Type': 'application/json;application/octet-stream'
    },
    params,
    responseType: 'blob'
  })
}

/**
 * @description: 获取k8s事件导出数据
 * @param {*} params
 * @return {*}
 */
export function getK8sEventExport(params) {
  return request2({
    url: PREFIX + '/monitor/export/type/k8s-event',
    method: 'get',
    headers: {
      'Content-Type': 'application/json;application/octet-stream'
    },
    params,
    responseType: 'blob'
  })
}


export function createReportAlarm(data) {
  return request({
    url: PREFIX +'/monitor/statistic/report/create/alarm',
    method: 'post',
    data
  })
}
export function createReportLog(data) {
  return request({
    url: PREFIX +'/monitor/statistic/report/create/log',
    method: 'post',
    data
  })
}
export function createReportEvent(data) {
  return request({
    url: PREFIX +'/monitor/statistic/report/create/event',
    method: 'post',
    data
  })
}

export function getReportList(data) {
  return request({
    url: PREFIX +'/monitor/statistic/report/list',
    method: 'post',
    data
  })
}

export function reportdDelete(data) {
  return request({
    url: PREFIX +'/monitor/statistic/report/delete',
    method: 'post',
    data
  })
}

export function reportdExport(data) {
  return request2({
    url: PREFIX + '/monitor/statistic/report/export',
    method: 'post',
    data,
    responseType: 'blob'
  })
}



